import { hashSync, genSaltSync, compareSync } from 'bcryptjs';

/** 生成随机盐 */
export const makeSalt = (): string => {
  return genSaltSync(10);
};

/** 加盐 */
export const genHash = (value: string, salt?: string | number): string => {
  return hashSync(value, salt);
};

/** 验证 */
export const compareValue = (value: string, hash: string): boolean => {
  return compareSync(value, hash);
};
